package com.fc.app.fcapp.recyclerview;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.widget.LinearLayout;

import com.fc.app.fcapp.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fc on 2018/2/25.
 */

public class HomeActivity extends Activity{
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.acitvity_recycler_view);
        List<String> dataList = new ArrayList();
        dataList.add("a");
        dataList.add("b");
        dataList.add("c");
        dataList.add("d");
        dataList.add("e");
        dataList.add("f");
        dataList.add("1");
        dataList.add("2");
        dataList.add("3");
        dataList.add("4");
        dataList.add("5");
        dataList.add("6");

        RecyclerView recyclerView= (RecyclerView) findViewById(R.id.recyclerview);
        recyclerView.setLayoutManager(new StaggeredGridLayoutManager(4,StaggeredGridLayoutManager.VERTICAL));//支持gridview
//        recyclerView.setLayoutManager(new LinearLayoutManager(this));//设置布局管理器（就是item的排列样式）
        recyclerView.setItemAnimator(new DefaultItemAnimator());//设置item增加和删除时的动画
//        recyclerView.addItemDecoration(new DividerItemDecoration(this, LinearLayout.VERTICAL));
        HomeAdapter adapter = new HomeAdapter(this,dataList);
        recyclerView.setAdapter(adapter);
    }
}
